package com.dxl.lanju.dao;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Repository;

import com.dxl.common.model.Page;
import com.dxl.common.utils.SqlBuilder;
import com.dxl.common.utils.Utils;
import com.dxl.dao.common.BaseDao;
import com.lanju.bean.StockBean;

/**
 * 库存管理DAO
 * @author 邓小林
 */
@Repository
public class StockDao extends BaseDao {
	private static final Logger LOG = Logger.getLogger(StockDao.class);
	
	public Page<StockBean> list(String areaId, String userId, String prodId, Integer state, Integer pageNo, Integer pageSize) {
		SqlBuilder sb = new SqlBuilder("select a.* from stock a where 1 = 1");
		if (Utils.isNotBlank(areaId)) {
			sb.appendStatement(" and a.area_id = ").appendParamValue(areaId);
		}
		if (Utils.isNotBlank(userId)) {
			sb.appendStatement(" and a.user_id = ").appendParamValue(userId);
		}
		if (Utils.isNotBlank(prodId)) {
			sb.appendStatement(" and a.prod_id = ").appendParamValue(prodId);
		}
		if (Utils.isNotNull(state)) {
			sb.appendStatement(" and a.state = ").appendParamValue(state);
		}
		sb.appendStatement(" order by a.created_time desc");
		return this.list(StockBean.class, sb.toStatement(), sb.toParams(), pageNo, pageSize);
	}
}
